
$('#btn').on('click',function(){
     let reg = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/;
     let $email = $('#email').val()
     if(!reg.test($email)){
        $('#modelId').modal();
         return;
     }
     if ($('#password').val() === '') {
         $('#modelId').modal();
         $('container-fluid').text('密码不能为空')
     }
     let data = $('.login-wrap').serialize();
    //  console.log(data);
     $.ajax({
         type:'post',
         url: '/admin/user/userLogin',
         data,
         success(res){
            if (res.code === 200) {
                console.log(res.data);
                // 把带回的头像和昵称存储到本地存储里面
                localStorage.setItem('avatar', res.data.avatar);
                localStorage.setItem('nickname', res.data.nickname);
                // 登录成功
                $('.container-fluid').text('登录成功');
                $("#modelId").modal();
                isLogin = true;
                
                 
            } else {
                // 提示失败
                $('.container-fluid').text('登录失败');
                $("#modelId").modal();
            }
         }
     });
     let isLogin=false;
     $('.modal-footer').on('click',function(){
         console.log(isLogin);
         if(isLogin){
             location.href = 'http://127.0.0.1:8080/admin/index.html';
         }else{
             $("#modelId").hide();
         }
     })
})